package com.hj.config.security.handler;

import com.hj.domain.HjToken;
import com.hj.domain.LoginUser;
import com.hj.service.HjTokenService;
import com.hj.util.CypherUtil;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description 登录用户处理
 * @author hj
 */
@Component
public class LoginUserHandler {

    private final HjTokenService hjTokenService;
    @Resource
    private CypherUtil cypherUtil;


    public LoginUserHandler(HjTokenService hjTokenService) {
        this.hjTokenService = hjTokenService;
    }

    public void packingUser(LoginUser loginUser) {
        HjToken hjToken = hjTokenService.save(loginUser);
        loginUser.setToken(hjToken.getToken());
        loginUser.setPassword(null);
        loginUser.setMobile(cypherUtil.aesDecode(loginUser.getMobile()));
    }


}
